  // 用户数据管理函数
        function initUserStats() {
            if (!localStorage.getItem('userStats')) {
                const registeredUsers = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
                const userStats = {};
                
                registeredUsers.forEach(user => {
                    userStats[user.username] = {
                        posts: Math.floor(Math.random() * 20),
                        comments: Math.floor(Math.random() * 50),
                        follows: Math.floor(Math.random() * 30),
                        points: 100 + Math.floor(Math.random() * 200)
                    };
                });
                
                localStorage.setItem('userStats', JSON.stringify(userStats));
            }
        }

        // 初始化用户统计数据
        document.addEventListener('DOMContentLoaded', initUserStats);

        // 创建Vue应用（Vue 2）
        new Vue({
            el: '#app',
            data() {
                return {
                    searchText: '',
                    currentUser: {},
                    userStats: {
                        posts: 0,
                        comments: 0,
                        follows: 0
                    }
                };
            },
            mounted() {
                this.checkLoginStatus();
            },
            methods: {
                handleSearch() {
                    console.log('执行搜索:', this.searchText);
                    if (this.searchText) {
                        alert(`搜索关键词: ${this.searchText}`);
                    }
                },
                handleInput() {
                    console.log('输入变化:', this.searchText);
                },
                // 检查登录状态
                checkLoginStatus() {
                    const currentUser = JSON.parse(localStorage.getItem('currentUser') || '{}');
                    if (currentUser.username) {
                        this.currentUser = currentUser;
                        this.loadUserData();
                    }
                },
                // 加载用户数据
                loadUserData() {
                    const userStats = JSON.parse(localStorage.getItem('userStats') || '{}');
                    if (userStats[this.currentUser.username]) {
                        this.userStats = userStats[this.currentUser.username];
                    }
                },
                // 跳转到个人中心
                goToProfile() {
                    if (this.currentUser.username) {
                        window.location.href = 'profile.html';
                    } else {
                        window.location.href = 'login.html';
                    }
                },
                // 登录
                login() {
                    window.location.href = 'login.html';
                },
                // 注册
                register() {
                    window.location.href = 'register.html';
                },
                // 退出登录
                logout() {
                    localStorage.removeItem('currentUser');
                    this.currentUser = {};
                    this.userStats = { posts: 0, comments: 0, follows: 0 };
                    alert('已退出登录');
                    location.reload();
                }
            }
        });